package Database;

import java.sql.Connection;
import java.sql.DriverManager;

public class Connect {
    public static Connection getConnection(){
        Connection conn = null;
        String driver = "com.mysql.jdbc.Driver";
        String URL = "jdbc:mysql://localhost:3306/homework_3";
        String USER = "root";
        String PASSWORD = "";
        try{
            Class.forName(driver);
            conn = DriverManager.getConnection(URL,USER,PASSWORD);
        }
        catch (Exception e){
            e.printStackTrace();
        }
        return conn;
    }

    public static void releaseConnection(Connection conn){
        try{
            if(conn!=null)
                conn.close();
        }
        catch (Exception e){
            e.printStackTrace();
        }
    }
}
